{#
Copyright (c) 2020 Andy Zhou
MIT License
#}
{% extends 'base.html' %}
{% from 'bootstrap/pagination.html' import render_pagination %}
{% from 'macros.html' import post_card, role_of with context %}
{% block title %}{{ _("Main") }}{% endblock %}
{% block scripts %}
    {{ super() }}
    <script>
        $(document).ready(function () {
            $('.profile-popover').hover(show_profile_popover.bind(this), hide_profile_popover.bind(this));
        })
    </script>
{% endblock scripts %}
{% block page_content %}
    {% if current_user.is_authenticated %}
    <div class="page-header">
        <h1 class="display-4">{{ _("Welcome,") }} {{ role_of(current_user) }} {{ current_user.username }}</h1>
    </div>
    {% endif %}
    <div class="row">
        <div class="col-md-8">
            <ul class="list-group">
            {% for post in posts %}
                {% if (not post.private) or post.author == current_user or current_user.is_administrator() %}
                    {{ post_card(post) }}
                {% endif %}
            {% endfor %}
            </ul>
        </div>
        {% include 'main/_sidebar.html' %}
    </div>
    <div class="pagination">
        {{ render_pagination(pagination) }}
    </div>
{% endblock %}

